package org.weed.remote.network.model;

import java.io.BufferedReader;
import java.io.IOException;

public class HttpRequest {
	private String header;
	
	public HttpRequest(String header) {
		this.header = header;
	}
	
	public String getHeader() {
		return header;
	}
	
	public static HttpRequest getRequest(BufferedReader reader) throws IOException {
		String line;
		StringBuilder builder = new StringBuilder();
		while (true) {
			line = reader.readLine();
			
			if (line == null) {
				throw new IOException("Connection closed.");
			} else if ("".equals(line)) {
					break;
			} else {
				builder.append(line + "\n");
			}
			
			
		}
		return new HttpRequest(builder.toString());
	}
}
